package com.zsj.juc.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @author <a href="https://gitee.com/zhengshengjun">zsj</a>
 * @date 2023/12/7.
 */
@Slf4j
public class Test6 {

    static int r = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(
                () -> {
                    log.debug("start....");
                    try {
                        TimeUnit.SECONDS.sleep(1);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    log.debug("stop....");
                    r = 10;
                }, "t1");
        t1.start();
//        t1.join();//等待此线程执行完毕
        log.debug("t1 over r={}", r);
        log.debug("end");
    }
}
